﻿@{
    ViewBag.Title = "ParseJsonDemo1";
    Layout = "~/Views/Shared/_Page.cshtml";
}

<h2>Parse Json Demo 1</h2>
<br />
<h3>Employee Info:</h3>
<hr />
<div id="empInfo"></div>

<script type="text/javascript">
    $(document).ready(function () {
        var url = "/Employee/MockEmployees";

        $.ajax({
            url: url,
            type: "Get",
            dataType: "json",
            success: function (data) {
                listEmployees(data);
            }
        });
    });

    function listEmployees(employees) {
        var html = "";

        for (var i = 0; i < employees.length; i++) {
            html += "<div>Id: " + employees[i].Id + "</div>"
                + "<div>Name: " + employees[i].Name + "</div>"
                + "<div>Title: " + employees[i].Title + "</div>"
                + "<div>Age: " + employees[i].Age + "</div>"
                + "<div>----------------------------------------</div>";
        }
        $("#empInfo").append(html);
    }
</script>
